package com.aaa.hospital.service.impl;

import com.aaa.hospital.mapper.DoctorResumeMapper;
import com.aaa.hospital.pojo.domain.Emp;
import com.aaa.hospital.pojo.domain.Resume;
import com.aaa.hospital.pojo.domain.UpShift;
import com.aaa.hospital.pojo.vo.DoctorVO;
import com.aaa.hospital.result.AjaxResult;
import com.aaa.hospital.service.DoctorResumeService;
import com.aaa.hospital.sysconst.LoginConst;
import org.omg.CORBA.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * ${Description}
 *
 * @author ZQ on 2022/2/19
 */

@Service
public class DoctorResumeServiceImpl implements DoctorResumeService {

    @Autowired
    private DoctorResumeMapper doctorResumeMapper;

    @Autowired
    private HttpSession httpSession;



    @Override
    public AjaxResult oneName(Integer id) {

        UpShift map = doctorResumeMapper.oneName(id);
        return AjaxResult.success(map);
    }

    @Override
    public AjaxResult getADoctor(Integer id) {
        List<Emp> doctorVO= doctorResumeMapper.getADoctor(id);
        if (doctorVO == null){
            return AjaxResult.fail();
        }
        System.out.println(doctorVO);
        return AjaxResult.success(doctorVO);
    }

    @Override
    public AjaxResult getId(Integer id) {

        int i = doctorResumeMapper.getId(id);
        return AjaxResult.success(i);
    }

    @Override
    public AjaxResult addResume(Resume resume) {

        int i = doctorResumeMapper.addResume(resume);
        System.out.println(i);

        return AjaxResult.success(i);
    }

    @Override
    public AjaxResult getAvatar(Integer id) {

        Emp emp = doctorResumeMapper.getAvatar(id);
        return AjaxResult.success(emp);
    }

    @Override
    public AjaxResult updateAvatar(DoctorVO doctorVO) {
        int i = doctorResumeMapper.updateAvatar(doctorVO);
        return AjaxResult.success(i);
    }

    @Override
    public AjaxResult getInfoID() {
        Emp emp = (Emp) httpSession.getAttribute(LoginConst.EMP_IN_SESSION);
        Integer id = emp.getId();
        return AjaxResult.success(id);
    }

    @Override
    public AjaxResult getDoctorResume(Integer id) {

        Resume resume = doctorResumeMapper.getDoctorResume(id);

        return AjaxResult.success(resume);
    }

    @Override
    public AjaxResult updateDoctorResume(Resume resume) {

        int i = doctorResumeMapper.updateDoctorResume(resume);

        return AjaxResult.success(i);
    }
}
